package com.bookshop.user.data;

import com.bookshop.dataOperator.DatabaseUtils;

public class UserModify implements UserCommonData,CustomerCommonData{

	public static final String CUSTOMER_TABLE = "customerdb";
	public static final String KEY="Account";

	public boolean modifyAccount(String pOldAccount, String pNewAccount) {
		String modifyUserSql = "update " + USER_TABLE + " set "+USER_ACCOUNT+"='"
				+ pNewAccount + "' where "+KEY+"='" + pOldAccount + "'";
		String modifyCustomerSql = "update " + CUSTOMER_TABLE
				+ " set "+ACCOUNT+"='" + pNewAccount + "' where "+KEY+"='"
				+ pOldAccount + "'";
		return DatabaseUtils.excute(modifyUserSql)&&DatabaseUtils.excute(modifyCustomerSql);
	}

	public boolean modifyPassword(String pAccount, String pNewPassword) {
		String modifySql = "update " + USER_TABLE + " set "+PASSWORD+"='"
				+ pNewPassword + "' where "+KEY+"='" + pAccount + "'";
		return DatabaseUtils.excute(modifySql);

	}

	public boolean modifyName(String pAccount, String newName) {
		String modifySql = "update " + CUSTOMER_TABLE + " set "+NAME+"='" + newName
				+ "' where "+KEY+"='" + pAccount + "'";
		return DatabaseUtils.excute(modifySql);
	}

	public boolean modifyCellNumber(String pAccount, String newCellNumber) {
		String modifySql="update "+CUSTOMER_TABLE+" set "+CELLNUMBER+"='"+newCellNumber+"' where "+KEY+"='"+pAccount+"'";
		return DatabaseUtils.excute(modifySql);
	}

	public boolean modifyAddress(String pAccount, String newAddress) {
		String modifySql="update "+CUSTOMER_TABLE+" set "+ADDRESS+"='"+newAddress+"' where "+KEY+"='"+pAccount+"'";
		return DatabaseUtils.excute(modifySql);
	}

}
